<%@ page language="java" contentType="text/html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Purchase Order Page</title>
<link rel="stylesheet" href="../../css/styles.css" type="text/css" />
<script type="text/javascript" src="js/validation.js"></script>
</head>
<script type="text/javascript">
	  function showSearchForm(){
	      document.getElementById("viewDiv").style.display = "block";
	  }
	  function setDisplay(){
	     var getDetailsField = document.getElementById("getDetailsField");
	     if(getDetailsField != null){
	        showSearchForm();
	     }
	  }
	  function validateFormOnSearch(theForm){
		var reason = "";
		
		reason +=validateSelectProduct(theForm.bitemSearch);
		if (reason !=""){
		alert("Error Message:\n" + reason);
		return false;
		}
		return true;
	}
	function newWindow(){
		window.open('PO.htm','jav','width=600,height=500,resizable=yes,scrollbars=1');
	} 
</script>
<body onLoad="javascript:setDisplay();">
<div id="container">
	<jsp:include page="/jsp/menu.jsp" />
	<div style="height:420px;">
  		<div class="path">
			<br><a href="home.htm"> Home </a>-&gt;
			<a> Account </a>-&gt;
			<a> Purchase </a>-&gt;
			<a href="purchaseOrder.htm"> Purchase Order </a>
  		</div>
  		<div id="leftDiv" style="margin-left: 10px;margin-top: 20px">
   			<b>Purchase Order Details</b><br><br>
				<fieldset style="height:50px; width:160px;background: #FFF;">
				<table cellpadding=20>
					<tr>
						<td>
							<a href="javascript:showSearchForm()">
		                        	View Purchase Order
							</a>
						</td>
					</tr>
				</table>
				</fieldset>
  		</div>
	</div>
	<form:form method="POST" action="getPurchaseOrder.htm" commandName="purchaseOrderDetails" onsubmit="return validateFormOnSearch(this)">
 	<div id="viewDiv" class="maininfo" style="display: none">
 		<div class="lable">
			Purchase Order
		</div>
		<div id="searchForm">
			<table>
				<tr>
					<th>Select Product <span class="mand-star">*</span></th>
					<td><form:select path="bitemSearch">
							<form:option value="option">----select----</form:option>
							<c:forEach items="${model.pList}" var="prodType">
								<form:option value="${prodType.strProdTypeDesc}">${prodType.strProdTypeDesc}</form:option>
							</c:forEach>
						</form:select></td>
				</tr>
				<tr>
					<th></th>
					<td><input type="submit" value="Search" size=5></td>
				</tr>
			</table>
		</div>
			<c:if test="${empty model.poList}">
				<div id="viewTable1">		
					Record Not Found
				</div>
			</c:if>
			
			<c:if test="${!empty model.poList}">
			 	<div id="viewTable">	
			     	<table  cellpadding="10">
						<tr>
							<th> Purchase No. </th>
							<th> Quot.No. </th>
							<th> Product </th>
							<th> Party </th>
							<th> Qty </th>
							<th> Rate </th>
							<th> Discount </th>
							<th> Amount </th>
							<th> Taxes </th>
							<th> Gross </th>
							<th> GeneratePO </th>
						</tr>
						<c:forEach items="${model.poList}" var="purchaseOrderForm">
						<tr>
							<td><c:out value="${purchaseOrderForm.numPONumber}"></c:out></td>
							<td><c:out value="${purchaseOrderForm.strQuotationNo}"></c:out></td>
							<td><c:out value="${purchaseOrderForm.strProdTypeDesc}"></c:out></td>
							<td></td>
							<td><c:out value="${purchaseOrderForm.numQuantity}"></c:out></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td><a href="javascript:newWindow()" >Click Here!</a></td>
						</tr>
						</c:forEach>
				 	</table>
				</div>
			</c:if>
		</div>
	</form:form>
	<c:if test="${model.isGet}">
	   		<input id="getDetailsField" type="hidden" name="getDetailsField"/>  
	</c:if>
	<div id="footer">
		<jsp:include page="/jsp/footer.jsp" />
	</div>
</div>
</body>
</html>
